package com.fancy.learncenter.adapter;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.activity.TrainVideoDetailActivity;
import com.fancy.learncenter.activity.VideoDetailActivity;
import com.fancy.learncenter.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.adapter.base.CustomViewHold;
import com.fancy.learncenter.bean.TrainListDataBean;
import com.superservice.lya.R;

import java.util.ArrayList;

/**
 * Created by hyy on 2018/2/24.
 * Explain activity as
 */

public class TrainVideoAdapter extends CommonRecycleViewAdapter<TrainListDataBean> {

    public TrainVideoAdapter(Context mContext, ArrayList<TrainListDataBean> itemDatas) {
        super(mContext, R.layout.fragment_train_video_item, itemDatas);
    }


    @Override
    public void bindView(CustomViewHold customViewHold, final TrainListDataBean item, int position) {
        SimpleDraweeView simpleDraweeView = customViewHold.getView(R.id.simpleDraweeView);
        simpleDraweeView.setImageURI(item.getImgsrc());


        TextView author = customViewHold.getView(R.id.author);
        author.setText(item.getAuthor());

        TextView play_num = customViewHold.getView(R.id.play_num);

        if (!TextUtils.isEmpty(item.getPlayed_num())) {
            play_num.setText(item.getPlayed_num() + "次播放");
        }


        TextView title = customViewHold.getView(R.id.title);
        title.setText(item.getTitle());
        customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, TrainVideoDetailActivity.class);

                intent.putExtra(VideoDetailActivity.VEDIO_KEY, item.getId());

                mContext.startActivity(intent);
            }
        });

    }
}
